package in.ac.dei.edrp.cms.daoimpl.reportgeneration;

import in.ac.dei.edrp.cms.dao.reportgeneration.ProgressCardDao;
import in.ac.dei.edrp.cms.domain.reportgeneration.ProgressCardInfo;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class ProgressCardImpl extends SqlMapClientDaoSupport implements ProgressCardDao{

	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> progressCardDetails(
			ProgressCardInfo progressCardInfo) {
		
		List<ProgressCardInfo> progressCardName = getSqlMapClientTemplate().queryForList("progressCard.getProgressCardName",progressCardInfo);
		return progressCardName;
	}
	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> progressCardMarksDetails(ProgressCardInfo progressCardInfo)
	{
		System.out.println("in marks details "+progressCardInfo.getProgramCourseKey()+" "+progressCardInfo.getRollNoForDetail()+" "+progressCardInfo.getSemesterStartDate()+" "+progressCardInfo.getSemesterEndDate());
		List<ProgressCardInfo> progressCardDetails = getSqlMapClientTemplate().queryForList("progressCard.getProgressCardMarks",progressCardInfo);		
		return progressCardDetails;
	}
	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> progressCardClass(ProgressCardInfo progressCardInfo) {				
		List<ProgressCardInfo> classInfo =  getSqlMapClientTemplate().queryForList("progressCard.getClassInfo",progressCardInfo);		
		return classInfo;
	}
	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> totalMarksDetails(
			ProgressCardInfo progressCardInfo) {
		System.out.println("in ttd "+progressCardInfo.getProgramCourseKey()+" "+progressCardInfo.getRollNoForDetail()+" "+progressCardInfo.getSemesterStartDate()+" "+progressCardInfo.getSemesterEndDate());
		List<ProgressCardInfo> getTotalMarks = getSqlMapClientTemplate().queryForList("progressCard.getTotalMarksDetails",progressCardInfo);
		System.out.println("ttdsiz "+getTotalMarks.size());
		return getTotalMarks;
	}
	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> getProgramCourseKeys(
			ProgressCardInfo progressCardInfo) {
		List<ProgressCardInfo> programCourseKey = getSqlMapClientTemplate().queryForList("progressCard.getProgramCourseKey",progressCardInfo);
		return programCourseKey;
	}			
	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> studentSatisfyingPCK(ProgressCardInfo progressCardInfo)
	{		
		System.out.println(progressCardInfo.getProgramId()+" "+progressCardInfo.getBranchId()+" "+progressCardInfo.getSpecializationId()+progressCardInfo.getSemesterStartDate()+" "+progressCardInfo.getSemesterEndDate()+" "+progressCardInfo.getProgramCourseKey());
		List<ProgressCardInfo> studentHavingPCK = getSqlMapClientTemplate().queryForList("progressCard.getStudentsSatisfyingPCK",progressCardInfo);
		return studentHavingPCK;
	}
	@SuppressWarnings("unchecked")
	public List<ProgressCardInfo> semestersBetTwoSemesters(
			ProgressCardInfo progressCardInfo) {
			
		List<ProgressCardInfo> semesters = getSqlMapClientTemplate().queryForList("progressCard.getSemestersBetweenTwoSemester",progressCardInfo);
		return semesters;
	}
	public ProgressCardInfo semesterIsGreater(ProgressCardInfo progressCardInfo) {
		System.out.println("in sem "+progressCardInfo.getInSemester()+"input sem "+progressCardInfo.getSemesterId()+progressCardInfo.getProgramId());
		ProgressCardInfo pci = (ProgressCardInfo) getSqlMapClientTemplate().queryForObject("progressCard.semesterIsGreater",progressCardInfo);
		return pci;
	}
	public ProgressCardInfo switchRules(ProgressCardInfo progressCardInfo) {
		System.out.println(progressCardInfo.getSequenceNumber()+" sn "+progressCardInfo.getSwitchNumber()+" rollno "+progressCardInfo.getRollNoForDetail()+" program "+progressCardInfo.getProgramId()+" branch "+progressCardInfo.getBranchId()+" sp "+progressCardInfo.getSpecializationId());			
		ProgressCardInfo switchRule = (ProgressCardInfo) getSqlMapClientTemplate().queryForObject("progressCard.getSwitchRule",progressCardInfo);
		return switchRule;
	}
	public ProgressCardInfo getPreviousCombination(
			ProgressCardInfo progressCardInfo) {
		System.out.println(progressCardInfo.getEnrollmentNumber() + " " +progressCardInfo.getRollNoForDetail()+progressCardInfo.getSwitchNumber()+progressCardInfo.getSequenceNumber());
		ProgressCardInfo previousCombination = (ProgressCardInfo) getSqlMapClientTemplate().queryForObject("progressCard.getCombinationBeforeSwitch",progressCardInfo);
		return previousCombination;
	}
	public ProgressCardInfo getSinglePCK(ProgressCardInfo progressCardInfo) {
		System.out.println("in pck "+progressCardInfo.getProgramId()+ " "+progressCardInfo.getBranchId()+" "+progressCardInfo.getSemesterId()+" "+progressCardInfo.getSpecializationId());
		ProgressCardInfo programCourseKey = (ProgressCardInfo) getSqlMapClientTemplate().queryForObject("progressCard.programCourseKey",progressCardInfo);
		return programCourseKey;
	}
	public ProgressCardInfo semesterStartEndDate(
			ProgressCardInfo progressCardInfo) {
		System.out.println("in date "+progressCardInfo.getProgramCourseKey()+" "+progressCardInfo.getEntityId()+" "+progressCardInfo.getRollNoForDetail());
			ProgressCardInfo date = (ProgressCardInfo) getSqlMapClientTemplate().queryForObject("progressCard.getSemesterStartEndDate",progressCardInfo);
		return date;
	}
	public ProgressCardInfo previousSemesterMarks(
			ProgressCardInfo progressCardInfo) {
		System.out.println(progressCardInfo.getRollNoForDetail()+"\n"+progressCardInfo.getProgramId()+"\n"+progressCardInfo.getSemesterId()+"\n"+progressCardInfo.getSpecializationId());		
		ProgressCardInfo marks = (ProgressCardInfo) getSqlMapClientTemplate().queryForObject("progressCard.getMarksOfSemesterByRollNo",progressCardInfo);		
		return marks;
	}
	
}
